package org.xiyinjihe.platform.util;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.UUID;

public class StringUtil {
    public static String uuid(){
        return UUID.randomUUID().toString().replace("-","");
    }

    public static String pad(String origStr,boolean isLeft,int totalLen,char padChar){
        if(null != origStr){
            if(origStr.length()<totalLen){
                for(int i=origStr.length();i<totalLen;i++){
                    if(isLeft){
                        origStr = padChar + origStr;
                    }else{
                        origStr = origStr + padChar;
                    }
                }
            }
        }
        return origStr;
    }

    public static String getVerCode_4(){
        Double i =Math.random() * 9000 + 1000;
        return String.valueOf(Math.round(i));
    }

    public static String formatNumber2(double money){
        BigDecimal amount = BigDecimal.valueOf(money);
        amount.setScale(2, BigDecimal.ROUND_DOWN);
        return new DecimalFormat("0.00").format(amount.doubleValue());
    }

    public static void main(String s[]){
        System.out.println(getVerCode_4());
    }
}
